﻿// Copyright: 2012 
// Author: Minh Vu - YoungJ
// File name: ReadnWrite.cs
// Solution: getlink
// Project: MediaFire
// Time: 3:12 PM 02/05/2012

using System;
using System.ComponentModel;
using System.Globalization;
using System.Xml;

namespace MediaFire
{
    public class MyBase : INotifyPropertyChanged
    {
        private int _percent;
        public int Percent
        {
            get { return _percent; }
            set
            {
                _percent = value;
                OnPropertyChanged("Percent");
            }
        }

        private string _error;
        public string Error
        {
            get { return _error; }
            set
            {
                if (string.IsNullOrEmpty(value)) return;
                _error = value;
                OnPropertyChanged("Error");
            }
        }

        #region Implementation of INotifyPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;
        protected void OnPropertyChanged(string info)
        {
            if (PropertyChanged != null && !string.IsNullOrEmpty(info))
                PropertyChanged(this, new PropertyChangedEventArgs(info));
        }

        #endregion
    }

    public static class Utils
    {
        public static string GetNodeText(this XmlNode xNode, string xpath)
        {
            var node = xNode.SelectSingleNode(xpath);
            return node != null ? node.InnerText : String.Empty;
        }
    }
}